package com.wise.eventserver.outsider.dao.impl;

import com.antlang.dao.AntDao;
import com.wise.common.base.repository.BaseRepository;
import com.wise.common.base.repository.impl.BaseRepositoryImpl;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CachePut;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;

@CacheConfig(cacheNames = "event")
@Repository("outsiderDao")
//@Service("outsiderDao")
public class OutsiderDaoImpl extends BaseRepositoryImpl<Object, Long> implements AntDao {

    //private BaseRepository baseRepository;

    //@CachePut(keyGenerator = "cacheKeyGenerator")
    @Override
    public <T> void saveOrUpdate(T t) {
        //genericDao.saveObject(o);
        //String className = o.getClass().getSimpleName();
        super.saveOrUp(t);
    }

    @Override
    public String save (Object o) {
        //String id = super.save(o).toString();
        //return id;
        super.saveObject(o);
        return "";
    }

    @Override
    public void delete (Object o) {
        //super.delete(o);
        super.deleteObject(o);
    }

    @Override
    public <T> T find (String query) {
        // 防止缓存中的是旧数据
        //getSession().clear();
        //T t = super.singleResult(query);
        //getSession().refresh(t);
        // 用完就清掉
        //getSession().clear();
        //return t;
        return null;
    }

/*
    @Override
    public <T> T flushFind (String query) {
        T t = super.singleResult(query);
        // 用完就清掉
        //getSession().clear();
        return t;
    }

    @Override
    public <T> List<T> flushFindList (String query) {
        getSession().flush();
        // 防止缓存中的是旧数据
        //getSession().clear();
        List<T> result = super.findByQueryString(query);
        // 用完就清掉
        //getSession().clear();
        return result;
    }
*/

    @Override
    public <T> List<T> findList (String query) {
        // 防止缓存中的是旧数据
        //List<T> result = super.findByQueryString(query);
        //return result;
        return null;
    }

    @Override
    public <T> T refreshEntity (T t) {
        //getSession().refresh(t);
        return t;
    }
}

